package com.kou.controller;/**
 * @author SteinY
 * @create 2022-03-28 9:41
 * @description:
 */

import com.alibaba.fastjson.JSONObject;
import com.kou.pojo.User;
import com.kou.service.impl.AdminServiceImple;
import com.kou.utils.Constants;
import com.qf.service.AdminService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * projectName:myshop2
 * author:SteinY
 * time:2022/3/28 9:41
 * description:
 */
@WebServlet("/getUserList")
public class GetUserListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AdminService adminService = new AdminServiceImple();
        List<User> users = adminService.findAll1();
        String userJson = JSONObject.toJSONString(users);
        response.getWriter().write(userJson);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AdminService adminService = new AdminServiceImple();
        List<User> users = adminService.findAll2();
        String userJson = JSONObject.toJSONString(users);
        response.getWriter().write(userJson);
    }
}